< previous page page_647 next page >

Page 647
(table continued from previous page)
PropertyDescription
BuddyPropertyThis identifies the name of the property to affect when the up or down arrow is clicked.
SyncBuddyYou must set this property to True to have the control automatically affect the BuddyControl property.
IncrementThis is the amount you want to use to increment or decrement the value in the BuddyControl property.
OrientationYou can have the UpDown control display either an up/down arrow or a left/right arrow.

Using the UpDown Control
In the example, the Salary text box has no code because it uses a numeric value. You use the AutoBuddy feature of the UpDown control to have the UpDown control affect the salary in the text box.
For the Birth Date text box, you need to write a little code to have the UpDown control affect the date in that text box:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub updDate_DownClick()
   If IsDate(txtBirthDate.Text) Then
      txtBirthDate.Text = CDate(txtBirthDate.Text) - _
                         updDate.Increment
   End If
End Sub
When the user clicks the down arrow, the DownClick event occurs. This event checks to see whether the Text property contains a valid date. If it does, it converts the value in the Text property to a date and decrements that value by the value in the Increment property of the UpDown control.
When the user clicks the up arrow, the UpClick event occurs. The same steps are performed in this event, except it increments the value by the value in the Increment property of the UpDown control. Heres the code:
9f31265bb40b592b1929e18a47ab28e5.gif
Private Sub updDate_UpClick()
   If IsDate(txtBirthDate.Text) Then
      txtBirthDate.Text = CDate(txtBirthDate.Text) + _
                         updDate.Increment
   End If
End Sub

 
< previous page page_647 next page >

If you like this book, buy it!